home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / comm / mail / YAMscripts.lha / CheckNewMail.rexx next >
OS/2 REXX Batch file  |  1996-11-19  |  4KB  |  131 lines

  1. /*                      CheckNewMail.rexx
  2.             v 1.2 - 19-Nov-96 
  3.  
  4.    This script checks if there are new or unread messages and where they are.
  5.    It requiress reqtools and rexxreqtools libraries.
  6.  
  7.    Changes in 1.2
  8.     - Output is slightly different
  9.     - Message counts should now always fit, even with long foldernames
  10.  
  11.    Changes in 1.1
  12.     - Displays number of new/unread messages in each folder
  13.     - All messages are now in variables and easy to change
  14.  
  15.    You can always get the latest version of this script by send a message
  16.    with subject REQUEST CheckNewMail.rexx to knikulai@utu.fi.  If you send
  17.    a message with subject REQUEST INDEX, you'll get a listing of all my
  18.    publicly available AREXX scripts.
  19. */
  20. options results
  21.  
  22. maxfolder=9    /* Set this to the number of folders you have-1*/
  23. cols=3        /* How many colums of folders in requester */
  24. wid=17        /* Max displayed width of foldername + message counts*/
  25. butl=70        /* Maximum length of buttons in characters. Increase this a bit
  26.                    if you are using a proportional font. */
  27. sunr='YES'    /* Search for unread messages too ( yes/no ) */
  28.  
  29. /* Change these to something you like */
  30.           title='CheckNewMail.rexx' 
  31.       new_title='You have new mail in following folders: (new/unread)' 
  32.    no_new_title='You have no new mail.'
  33.    unread_title='You have unread mail in following folders:' 
  34. no_unread_title='You have no folders with only unread mail.'
  35.   select_folder='Select folder you want to read next'
  36.     last_button='_Done'
  37.  
  38. addlib('rexxreqtools.library',0,-30)
  39. address 'YAM' 
  40.  
  41. GetFolderInfo Number    /* Let's remember where we are now */
  42. orig_fold=result
  43. GetMailInfo Active
  44. orig_msg=result
  45.  
  46. nc=0        /* new-counter */
  47. uc=0        /* unread-counter */
  48. NL='0a'x    /* newline */
  49. do f=0 to maxfolder
  50.    if f~=1 & f~=2 then do  /* Don't check Outgoing nor Sent */
  51.         SetFolder f
  52.      GetFolderInfo Name
  53.     fn=result        /* Name of the folder */
  54.     GetFolderInfo Max
  55.     n=result        /* Number of messages in the folder */
  56.     i=0
  57.     nm=0
  58.     um=0
  59.     do while i<n
  60.        SetMail i
  61.        i=i+1
  62.        GetMailInfo Status
  63.        if result='N' then nm=nm+1    /* New message was found */
  64.        if result='U' & upper(sunr)='YES' then um=um+1/* Unread message was found */
  65.     end /* do while i<n */
  66.     if nm>0 then do  /* New messages were found */
  67.        nc=nc+1
  68.        foo= nm ||'/'|| um 
  69.        new.nc=left(fn||' ',wid-length(foo), '.') || foo
  70.        newn.nc=f
  71.        end
  72.     else
  73.     if um>0 & upper(sunr)='YES' then do  /* New messages were found */
  74.        uc=uc+1       
  75.        unread.uc=left(fn||' ', wid-length(um), '.') || um
  76.        unreadn.uc=f
  77.        end
  78.     
  79.     end /* if f~=1 & f`=2 then do */    
  80. end /* do f=0 to maxfolder */
  81.  
  82. /* Now all folders have been scanned */
  83. but=''
  84. bc=0
  85.  
  86. /* Return to where we were before starting this script */
  87. 'SetFolder' orig_fold
  88. 'SetMail' orig_msg
  89.  
  90. /* Let's first list new messages */
  91. if nc>0 then 
  92.       rt=new_title
  93. else 
  94.       rt=no_new_title || NL
  95.  
  96. rt=rt || NL
  97. do i=1 to nc
  98.     rt=rt || new.i || '  '
  99.     if length(but)+length(word(new.i,1))<butl then do 
  100.         but=but || word(new.i,1) || '|'
  101.         bc=bc+1
  102.         butn.bc=newn.i
  103.         end
  104.     if i//cols = 0 then rt=rt || NL
  105. end
  106.  
  107. /* Then it's time to list unread messages, if that was asked */
  108. if upper(sunr)='YES' then do
  109.     if uc>0 then 
  110.         rt=rt||NL|| unread_title
  111.     else 
  112.         rt=rt||NL|| no_unread_title
  113.     rt=rt || NL
  114.     do i=1 to uc
  115.         rt=rt || unread.i ||'  '
  116.         if i//cols = 0 then rt=rt || NL
  117.         if length(but)+length(word(unread.i,1))<butl then do
  118.             but=but || word(unread.i,1) || '|'
  119.             bc=bc+1
  120.             butn.bc=unreadn.i
  121.             end
  122.     end
  123. end /* if upper(sunr)='YES' */
  124.  
  125. rt=rt || NL || NL || select_folder
  126. but=but || last_button
  127. tags='rtez_defaultresponse=0'
  128.  
  129. sel=rtezrequest(rt,but,title,tags)
  130. if sel>0 then address 'YAM' 'SetFolder ' || butn.sel
  131.